package com.sxm.yiwei.pinche;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sxm.yiwei.MainActivity;
import com.sxm.yiwei.R;
import com.sxm.yiwei.base.BaseActivity;
import com.sxm.yiwei.constant.Constant;


public class CompleteActivity extends BaseActivity implements View.OnClickListener {

    private RelativeLayout rl_back;
    private TextView tv_title;
    private TextView tv_msg;
    private TextView text2;
    private TextView text1;
    private Button btn_see_others;
    private int type;
    private String text_1;
    private String text_2;
    private String title;
    private String msg;


    @Override
    public void setContentView() {
        setContentView(R.layout.activity_complete);
        type = getIntent().getIntExtra("type",-1);
        text_2 = getIntent().getStringExtra("text_2");
        text_1 = getIntent().getStringExtra("text_1");
    }

    @Override
    public void initView() {
        rl_back = (RelativeLayout)findViewById(R.id.rl_back);
        tv_title = (TextView)findViewById(R.id.tv_title);
        tv_msg = (TextView)findViewById(R.id.tv_msg);
        text1 = (TextView)findViewById(R.id.text1);
        text2 = (TextView)findViewById(R.id.text2);
        btn_see_others = (Button)findViewById(R.id.btn_see_others);

    }

    @Override
    public void initListener() {
        rl_back.setOnClickListener(this);
        btn_see_others.setOnClickListener(this);
    }

    @Override
    public void initData() {
        switch (type){
            case Constant.RELEASE_OK:
                btn_see_others.setVisibility(View.VISIBLE);
                tv_title.setText("发布成功");
                tv_msg.setText("路线信息发布成功");
                text1.setText("出发时间："+text_1);
                text2.setText("订单号："+text_2);
                break;
            case Constant.REFUND_OK:
                btn_see_others.setVisibility(View.VISIBLE);
                tv_title.setText("退票完成");
                tv_msg.setText("退票完成");
                text1.setText("行程路线："+text_1);
                text2.setText("订单号："+text_2);
                break;
            case Constant.CHANGE_OK:
                btn_see_others.setVisibility(View.GONE);
                tv_title.setText("改签成功");
                tv_msg.setText("改签成功");
                text1.setText("现出发时间：");
                text2.setText("订单号：");
                break;
            case Constant.PASSENGER_ROB_OK:
                btn_see_others.setVisibility(View.VISIBLE);
                tv_title.setText("购票成功");
                tv_msg.setText("购票成功");
                text1.setText("出发时间："+text_1);
                text2.setText("订单号："+text_2);
                break;
            case Constant.HOST_ROB_OK:
                btn_see_others.setVisibility(View.VISIBLE);
                tv_title.setText("抢单成功");
                tv_msg.setText("抢单成功");
                text1.setText("出发时间："+text_1);
                text2.setText("订单号："+text_2);
                break;
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_see_others:
                startActivity(new Intent(this, MainActivity.class));
                finish();
                break;
            case R.id.rl_back:
                onBackPressed();
                break;
        }
    }

    @Override
    public void onBackPressed() {
        if (type==Constant.RELEASE_OK){
            startActivity(new Intent(this,PincheActivity.class));
        }else if (type==Constant.CHANGE_OK||type==Constant.REFUND_OK){
            // TODO: 2017/11/9
            startActivity(new Intent(this,PincheOrderActivity.class));

        }else if (type==Constant.PASSENGER_ROB_OK||type==Constant.HOST_ROB_OK){
            startActivity(new Intent(this,PincheActivity.class));
        }
        super.onBackPressed();
    }
}
